home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JZSCRPRN.ASM < prev    next >
Assembly Source File  |  1988-12-18  |  3KB  |  107 lines

  1. Comment *
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │title     : jzscrprn                                 │
  4. │Purpose : print directly to the screen buffer without snow             │
  5. │ds:si     points to the string to write                         │
  6. │bh    contains the attribute                             │
  7. │ah    contains the column, al contains the row                 │
  8. │written by Jack A. Zucker on 1/30/86 (301) 794-5950 75766,1336          │
  9. └────────────────────────────────────────────────────────────────────────────┘
  10.  *
  11. title    print directly to screen buffer
  12. name    jzscrprn
  13.  
  14.     assume cs:_text
  15. _text    segment public byte 'code'
  16.     public _jzscrprn
  17.  
  18. _jzscrprn     proc     near
  19.     push bp
  20.     mov bp,sp
  21.     push si
  22.     push di
  23.     push ds
  24.     push es
  25.     mov al,[bp+6]        ; get row
  26.     mov bx,50h        ; 50 columns (hex)
  27.     mul bl            ; row offset = # columns * row
  28.     mov bx,ax        ; put value back in bx
  29.     add bx,[bp+8]        ; add column
  30.     shl bx,1        ; multiply by 2
  31.     mov di,bx        ; screen seg:di = offset for writing
  32.  
  33.     mov bh,[bp+0Ah]     ; get attribute back in bh
  34.  
  35.     push ds         ; save ds for mode check
  36.     mov ax,40h        ; low memory information segment
  37.     mov ds,ax
  38.     mov si,49h        ; screen mode
  39.     cmp byte ptr [si],7    ; 7 = mono mode
  40.     mov si,[bp+4]        ; get offset of first character
  41.     pop es            ; restore our data into extra segment
  42.     jz mono         ; [si] = 7 means mono mode
  43.     mov ax,0b800h        ; color screen segment
  44.     mov ds,ax
  45. next:
  46.     mov bl,es:[si]
  47.     or bl,bl
  48.     jz endofdsp        ; 0 = end of string
  49.     mov dx,3dah        ; address of 6845 Status register
  50.  
  51. Comment *
  52. ┌────────────────────────────────────────────────────────────────────────────┐
  53. │ This next section which only gets executed in color mode checks the status │
  54. │ register of the 6845 crt controller chip. When bit 0 is set to 1 we can    │
  55. │ update the screen without snow. The process is to check to see if it's set │
  56. │ to one and loop until it's not. Then loop until it's High and fall out of  │
  57. │ the loop and write the character. The reason it's done this way is in case │
  58. │ you initially check the status and it's at the very end of a retrace. In   │
  59. │ that case, you would think that it is safe to write to the screen buffer   │
  60. │ but my way takes care of a partially complete retrace on the first try.    │
  61. │ Examine the code on pertaining to bios int 9 in the Ibm technical reference│
  62. │ manual. Note that this code is unnecessary for many compatibles as they do │
  63. │ not have the same bug in their displays as the Ibm pc does.             │
  64. └────────────────────────────────────────────────────────────────────────────┘
  65.  *
  66.  
  67. status_low:
  68.     in al,dx        ; get vertical retrace status
  69.     ror al,1        ; faster than test
  70.     jc status_low        ; wait for partially done retrace
  71.     cli            ; don't allow any more interrupts
  72. status_high:
  73.     in al,dx        ; wait for beginning of new retrace
  74.     ror al,1
  75.     jnc status_high     ; retrace not started
  76.  
  77.     sti            ; interrupt allowed now
  78.     mov [di],bx        ; place character and attribute in screen buf
  79.     inc di            ; point to next position (attribute)
  80.     inc di            ; point to next position (character)
  81.     inc si
  82.     jmp next
  83.  
  84. mono:
  85.     mov ax,0b000h        ; Mono screen segment
  86.     mov ds,ax
  87. next2:
  88.     mov bl,es:[si]           ; character to print
  89.     or bl,bl        ; 0 = end of string
  90.     jz endofdsp
  91.     mov [di],bx        ; place character and attribute in screen buf
  92.     inc di            ; point to next position (attribute)
  93.     inc di            ; point to next position (character)
  94.     inc si
  95.     jmp next2
  96. endofdsp:
  97.     pop es
  98.     pop ds
  99.     pop di
  100.     pop si
  101.     mov sp,bp
  102.     pop bp
  103.     ret
  104. _jzscrprn endp
  105. _text ends
  106. end
  107.